package com.tron.dobest.java.trondesign.template;

public abstract class CaffeineBeverageWithHook {
    void prepareRecipe() {
        boilWater();
        brew();
        pourInCup();
        if (customerWantsCondiments()) {
            addCondiments();
        }
    }

    /**
     * 酿造
     */
    protected abstract void brew();

    /**
     * 添加调味品
     */
    protected abstract void addCondiments();

    /**
     * 可以被子类覆盖的钩子函数
     * @return
     */
    public boolean customerWantsCondiments() {
        return false;
    }

    private void pourInCup() {
        System.out.println("导入杯子");
    }

    private void boilWater() {
        System.out.println("烧水");
    }
}
